// Get the "pinyinizer." branch
var prefs = Components.classes["@mozilla.org/preferences-service;1"].
                    getService(Components.interfaces.nsIPrefService);
prefs = prefs.getBranch("pinyinizer.");

function savePrefs() {
   prefs.setCharPref('view', document.getElementById('view').selectedItem.value);
}

function loadPrefs() {
   try {  // get the pref
	var value = prefs.getCharPref('view');
	document.getElementById('view').selectedItem = document.getElementById(value);
   }
   catch(e) {  // if pref doesnt exist, create it
	document.getElementById('view').selectedItem = document.getElementById('sidebar');
   }
}